import * as echarts from 'echarts';

export default function ( dom, opt ) {
    let myChart = echarts.init (dom);
    let option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                lineStyle: {
                    color: '#57617B'
                }
            }
        },
        legend: {
            icon: 'rect',
            itemWidth: 14,
            itemHeight: 5,
            itemGap: 13,
            data: [ '月好评总数', '好评总数' ],
            right: '4%',
            textStyle: {
                fontSize: 12,
                color: '#F1F1F3'
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [ {
            type: 'category',
            boundaryGap: false,
            axisLine: {
                lineStyle: {
                    color: '#57617B'
                }
            },
            data: [ "第一月", "第二月", "第三月", "第四月" ]
        } ],
        yAxis: [ {
            type: 'value',
            axisTick: {
                show: false
            },
            axisLine: {
                lineStyle: {
                    color: '#57617B'
                }
            },
            axisLabel: {
                margin: 10,
                textStyle: {
                    fontSize: 14
                }
            },
            splitLine: {
                lineStyle: {
                    color: '#57617B'
                }
            }
        } ],
        series: [
            {
                name: '月好评总数',
                type: 'line',
                smooth: true,
                symbol: 'circle',
                symbolSize: 5,
                showSymbol: false,
                lineStyle: {
                    width: 1
                },
                areaStyle: {
                    color: new echarts.graphic.LinearGradient (0, 0, 0, 1, [ {
                        offset: 0,
                        color: 'rgba(87,234,253,0.55)'
                    }, {
                        offset: 0.8,
                        color: 'rgba(137, 189, 27, 0)'
                    } ], false),
                    shadowColor: 'rgba(0, 0, 0, 0.1)',
                    shadowBlur: 10
                },
                itemStyle: {
                    color: '#2CD1F9',
                    borderColor: 'rgba(87,234,253,.5)',
                    borderWidth: 12
                },
                data: [ ...opt.count ]
            },
            {
                name: '好评总数',
                type: 'line',
                smooth: true,
                symbol: 'circle',
                symbolSize: 5,
                showSymbol: false,
                lineStyle: {
                    width: 1
                },
                areaStyle: {
                    color: new echarts.graphic.LinearGradient (0, 0, 0, 1, [ {
                        offset: 0,
                        color: 'rgba(249,199,44,0.55)'
                    }, {
                        offset: 0.8,
                        color: 'rgba(0, 136, 212, 0)'
                    } ], false),
                    shadowColor: 'rgba(0, 0, 0, 0.1)',
                    shadowBlur: 10
                },
                itemStyle: {
                    color: '#F9C72C',
                    borderColor: 'rgba(249,199,44,0.5)',
                    borderWidth: 12
                },
                data: [ ...opt.sum ]
            },
        ]
    };
    myChart.setOption (option)
}
